import type { AddressItem } from '@/types/address'
import { defineStore } from 'pinia'
import { ref } from 'vue'

// 定义当前选中地址的pinia。全局管理选中的地址
export const useAddressStore = defineStore('address', () => {
  // 选中的收货地址
  const selectedAddress = ref<AddressItem>()

  // 修改后的收货地址
  const changeSelectedAddress = (val: AddressItem) => {
    selectedAddress.value = val
  }

  return { selectedAddress, changeSelectedAddress }
})
